<script>
	import Header from "@/components/Header.vue"
	import Modal from "@/components/Modal.vue"
	export default {
		components: {
			Modal,
			Header
		},
		data() {
			return {
				title: "提现",
				info:{},
				amount:'',
				check_flag:false,
				
				readed: false,
				modalShow: false,
				withdrawal_rule_arr:''
			}
		},
		onLoad(options) {
			var info = uni.getStorageSync('getFundInfo')
			this.info = info
			
			if(uni.getStorageSync('getIsFx')){
				if(uni.getStorageSync('getIsFx').is_sqtx=='1'){
					this.modalShow = true
				}
			}
			console.log(uni.getStorageSync('getIsFx').is_sqtx)
		},
		onShow() {
			var that = this
			var info = uni.getStorageSync('getFundInfo')
			this.info = info
			uni.request({
				url:getApp().globalData.host+'/api/Fund/getFundInfo',
				header: {
					memberid:uni.getStorageSync('member_id'),
					membertoken:uni.getStorageSync('member_token'),
				},
				success:(rrr) => {
					uni.setStorageSync('getFundInfo',rrr.data.data)
					that.info.money = rrr.data.data.money
					that.withdrawal_rule_arr = rrr.data.data.withdrawal_rule_arr
				},
			})
		},
		onShareAppMessage() {
			this.readedFn2()
			if(uni.getStorageSync('info')){
				this.info = uni.getStorageSync('info')
				return {
					title: '发布消息找到那个他/她',
					path: '/pages/index/index?id='+this.info.me_invite_code,
					imageUrl: "https://seekerxcxoss.yiyankeji.vip/Label/Share_img.png"
				}
			}else{
				return {
					title: '发布消息找到那个他/她',
					path: '/pages/index/index',
					imageUrl: "https://seekerxcxoss.yiyankeji.vip/Label/Share_img.png"
				}
			}
		},
		methods: {
			readedFn2() {
				this.modalShow = false
				this.readed = true
				//uni.setStorageSync("readed", "1")
			},
			tixianDo(){
				var that = this
				if(that.amount<=0){
					uni.showModal({
						content:'请输入提现金额'
					})
					return
				}
				if(that.amount==''){
					uni.showModal({
						content:'请输入提现金额'
					})
					return
				}
				
				that.check_flag = true
				
				uni.request({
					url:getApp().globalData.host+'/api/Fund/actionWithdrawNew',
					data:{
						withdraw_num:that.amount
					},
					header: {
						memberid:uni.getStorageSync('member_id'),
						membertoken:uni.getStorageSync('member_token'),
					},
					success:(r) => {
						if(r.data.code!=200){
							uni.showModal({
								content:r.data.msg
							})
						}else{
							uni.showModal({
								content:'提现成功'
							})
							uni.request({
								url:getApp().globalData.host+'/api/My/getMyInfo',
								header: {
									memberid:uni.getStorageSync('member_id'),
									membertoken:uni.getStorageSync('member_token'),
								},
								success:(rr) => {
									uni.setStorageSync('info',rr.data.data)
								},
							})
							
							uni.request({
								url:getApp().globalData.host+'/api/Fund/getFundInfo',
								header: {
									memberid:uni.getStorageSync('member_id'),
									membertoken:uni.getStorageSync('member_token'),
								},
								success:(rrr) => {
									uni.setStorageSync('getFundInfo',rrr.data.data)
									that.info.money = rrr.data.data.money
									that.withdrawal_rule_arr = rrr.data.data.withdrawal_rule_arr
								},
							})
						}
					},
				})
			}
		}
	}
</script>
<template>
	<view class="custom-bg">
		<Header :title="title"></Header>
		
		
		<div class="mask flex"  style="justify-content: center;align-items: flex-start;padding-top: 320rpx;" v-if="modalShow"> <!--@click="readedFn2"-->
			<div class="flex-col relative" style="margin-top:100rpx">
				<image src="/static/mask/line.png" class="absolute" mode="widthFix"
					style="width:170rpx;right:-50rpx; top:-250rpx"></image>
				<image src="/static/mask/title.png" mode="widthFix" style="width:500rpx"></image>
				<image src="/static/mask/pic.png" mode="widthFix" style="width:500rpx"></image>
				<div class="center mt-50" style="display: none;">
					<image src="/static/mask/confirm.png" mode="widthFix" style="width:214rpx"></image>
				</div>
			</div>
		</div>
		
		
		<div class="p-30">

			<div class="bg-white p-30">
				<div class="fz28 text-gray-16">可提现： {{info.money}}茶水费</div>
				<div class="line my-30"></div>

				<div class="between">
					<div class="flex">
						<image src="/static/my/wpay.png" mode="widthFix" class="w-55 "></image>
						<div class="fz28 text-gray-16 ml-16">微信</div>
					</div>
					<radio value="" color="#333" style="transform: scale(0.8);" checked="checked" />
				</div>
				<div class="line my-30"></div>
				<div class="flex">
					<div class="fz28 text-gray-16 flex-shirnk-0"> 提现茶水费：</div>
					<input type="number" class="w-full" placeholder="请输入需要提现的茶水费" v-model="amount">
				</div>
			</div>

			<div class="bg-white mt-20 p-30 text-black">
				<div class="fz28">{{withdrawal_rule_arr[0]}}</div>
				<div class="fz24 mt-20">{{withdrawal_rule_arr[1]}}</div>
				<div class="fz24 mt-20">{{withdrawal_rule_arr[2]}}</div>
				<div class="fz24 mt-20">{{withdrawal_rule_arr[3]}}</div>
				<div class="fz24 mt-20">{{withdrawal_rule_arr[4]}}</div>
				<div class="fz24 mt-20">{{withdrawal_rule_arr[5]}}</div>
				<div class="fz24">{{withdrawal_rule_arr[6]}}</div>
			</div>


		</div>

		<div class="submit  text-white p-30 bg-white">
			<label class="radio flex text-gray-16 mb-30 ml-20 fz24">
				<radio color="#333" style="transform: scale(0.8);" :checked="check_flag" />
				<div>提现即代表同意 <text class="text-purple">《云账户灵活用工协议》</text> <text class="text-purple">《用户行为规范》</text>
				</div>
			</label>
			<div class="bg-purple center h-90 rounded-50" @click="tixianDo">
				立即提现
			</div>
		</div>


		<div class="fz30 text-gray-16 text-purple center flex" @click="go('/pages/my/wallet/log?type=3')">
			提现记录 <image src="/static/message/right.png" mode="widthFix" class="w-15 ml-16 mt-5"></image>
		</div>


	</view>


</template>



<style>
	.submit {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-shadow: 0 -10rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	.custom-bg {
		min-height: 100%;
	}

	.avatar-group {
		position: relative;
	}

	page {
		height: 100%;
		background-color: #F8F8F8;
	}
	
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 99;
	}
</style>